<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- <script src="https://cdn.tailwindcss.com"></script> -->
    <script src="/tailwind/cdnjs/tailwind-3.4.16.js"></script>
    <!-- 开发环境版本，包含了有帮助的命令行警告 -->
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
</head>

<body>
    <div id="app">
        {{ message }}
    </div>
    <div id="app-2">
        <span v-bind:title="message">
            鼠标悬停几秒钟查看此处动态绑定的提示信息！
        </span>
    </div>
    <div id="app-3">
        <p v-if="seen">现在你看到我了</p>
    </div>
    <div id="app-4">
        <ol>
            <li v-for="(todo, index) in todos" class="underline list-none font-semibold text-red-500">
                {{ todo.text }}-{{index}}
            </li>
        </ol>
    </div>

    <div id="app-5">
        <p>{{ message }}</p>
        <button v-on:click="reverseMessage" class="
            underline-green-500 rounded-lg 
            bg-blue-500  text-white font-bold 
            py-2 px-4">反转消息</button>
    </div>

    <div id="app-6">
        <p>{{ message }}</p>
        <input v-model="message">
    </div>

    <div id="app7">
        <ol>
            <!-- 创建一个 todo-item 组件的实例 -->
            <todo-item></todo-item>
        </ol>
    </div>


    <script>
        // 定义名为 todo-item 的新组件
        Vue.component('todo-item', {
            template: '<li>这是个待办项</li>',
            script: {
                data: function () {
                    return {
                        message: '待办项'
                    }
                }
            },
            // 组件的选项
            // ...
            data: function () {
                return {
                    message: '待办项'
                }
            }
        })

        var app = new Vue({
            el: '#app7'
        })
        var app6 = new Vue({
            el: '#app-6',
            data: {
                message: 'Hello Vue!'
            }
        })
        var app5 = new Vue({
            el: '#app-5',
            data: {
                message: '1234567890'
            },
            methods: {
                reverseMessage: function () {
                    this.message = this.message.split('').reverse().join('')
                    // console.log(this.message)
                    // this.message = (this.message === 'Hello Vue.js!') ? "message" : 'Hello Vue.js!';
                }
            }
        })
        var app = new Vue({
            el: '#app',
            data: {
                message: 'Hello Vue!'
            }
        })
        var app2 = new Vue({
            el: '#app-2',
            data: {
                message: '页面加载于 ' + new Date().toLocaleString()
            }
        })
        var app3 = new Vue({
            el: '#app-3',
            data: {
                seen: false
            }
        })

        var app4 = new Vue({
            el: '#app-4',
            data: {
                todos: [
                    { text: '学习 JavaScript' },
                    { text: '学习 Vue' },
                    { text: '整个牛项目' }
                ]
            }
        })
    </script>
</body>

</html>